package com.peko.interceptor.config;

import com.peko.interceptor.interceptor.MyInterceptor1;
import com.peko.interceptor.interceptor.MyInterceptor2;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author Peko
 */
@Configuration
public class MvcConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new MyInterceptor1()) //指定拦截器
                .addPathPatterns("/**")  //拦截所有
                .order(1);  //指定拦截器执行顺序

        registry.addInterceptor(new MyInterceptor2()) //指定拦截器
                .addPathPatterns("/**")  //拦截所有
                .order(2);  //指定拦截器执行顺序
    }
}
